package com.gongpingjialoan.activity.tool;

import com.gongpingjialoan.R;
import com.gongpingjialoan.activity.main.BaseActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

/**
 * 车辆出险记录查询
 * 
 * @author Administrator
 * 
 */
public class InsuranceActivity extends BaseActivity
{
    
    private EditText vinView;
    
    private EditText engineView;
    
    private Button submit2;
    
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_insurance);
        
        initBase(this);
        setTitle("出险记录查询");
        vinView = (EditText)findViewById(R.id.vin);
        engineView = (EditText)findViewById(R.id.edit_engine);
        
        submit2 = (Button)findViewById(R.id.submit_2);
        
        setButtonListener();
        
    }
    
    private void setButtonListener()
    {
        submit2.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                if (vinView.getText().toString().trim().equals(""))
                {
                    showTips(2, "请输入车架号!");
                    return;
                }
                
                if (vinView.getText().toString().trim().length() != 6)
                {
                    showTips(2, "车架号不是6位,请重新输入!");
                    return;
                }
                if (engineView.getText().toString().trim().equals(""))
                {
                    showTips(2, "请输入发动机号!");
                    return;
                }
                
                if (engineView.getText().toString().trim().length() != 6)
                {
                    showTips(2, "发动机号不是6位,请重新输入!");
                    return;
                }
                
                Intent it = new Intent(InsuranceActivity.this, InsuranceResultActivity.class);
                it.putExtra("vin", vinView.getText().toString());
                it.putExtra("engine", engineView.getText().toString());
                startActivity(it);
            }
        });
    }
    
}
